package com.fr.web.core;

import com.fr.base.FRContext;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Attachment
  implements Serializable, Cloneable
{
  private static final long serialVersionUID = -7473236027008758695L;
  public static final String ID = "attach_id";
  public static final String TYPE = "attach_type";
  private String id;
  private String type;
  private String filename;
  private byte[] bytes;

  public Attachment(String paramString1, String paramString2, String paramString3, byte[] paramArrayOfByte)
  {
    this.id = paramString1;
    this.type = paramString2;
    this.filename = paramString3;
    this.bytes = paramArrayOfByte;
  }

  public String getID()
  {
    return this.id;
  }

  public String getType()
  {
    return this.type;
  }

  public String getFilename()
  {
    return this.filename;
  }

  public byte[] getBytes()
  {
    return this.bytes;
  }

  public JSONObject toConfig()
  {
    try
    {
      return new JSONObject().put("attach_type", getType()).put("attach_id", getID());
    }
    catch (JSONException localJSONException)
    {
      FRContext.getLogger().log(Level.WARNING, localJSONException.getMessage(), localJSONException);
      throw new RuntimeException(localJSONException);
    }
  }
}